﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace popLib.ModelSystem
{
    public class FormAction
    {
        public FormAction(bool AllAction = false, string ExtraParam = null)
        {
            this.EditRecord = AllAction;
            this.AddRecord = AllAction;
            this.DisposeRecord = AllAction;
            this.ConfirmRecord = AllAction;
            this.ViewRecord = AllAction;
            this.SelectRecord = AllAction;
            this.ViewRecordOwner = AllAction;
            this.EditRecordOwner = AllAction;
            this.DisposeRecordOwner = AllAction;
            this.ConfirmRecordOwner = AllAction;
            this.PrintRecord = AllAction;
            this.PrintRecordOwner = AllAction;
            this.ExtraParam = ExtraParam;
        }

        /// <summary>
        /// For look up perpose only
        /// </summary>


        public FormAction(bool EditRecord, bool ViewRecord, bool AddRecord, bool DisposeRecord, bool ConfirmRecord, bool SelectRecord, bool ViewRecordOwner = false, bool EditRecordOwner = false, bool DisposeRecordOwner = false, bool ConfirmRecordOwner = false, bool PrintRecord = false, bool PrintRecordOwner = false, string ExtraParam = null)
        {
            this.EditRecord = EditRecord;
            this.AddRecord = AddRecord;
            this.DisposeRecord = DisposeRecord;
            this.ConfirmRecord = ConfirmRecord;
            this.ViewRecord = ViewRecord;
            this.SelectRecord = SelectRecord;
            this.ViewRecordOwner = ViewRecordOwner;
            this.EditRecordOwner = EditRecordOwner;
            this.DisposeRecordOwner = DisposeRecordOwner;
            this.ConfirmRecordOwner = ConfirmRecordOwner;
            this.PrintRecord = PrintRecord;
            this.PrintRecordOwner = PrintRecordOwner;
            this.ExtraParam = ExtraParam;
        }

        public FormAction(dynamic menu)
        {
            this.EditRecord = (bool)menu.FullPermission ? true : (bool)menu.EditRecord;
            this.AddRecord = (bool)menu.FullPermission ? true : (bool)menu.AddRecord;
            this.DisposeRecord = (bool)menu.FullPermission ? true : (bool)menu.DisposeRecord;
            this.ConfirmRecord = (bool)menu.FullPermission ? true : (bool)menu.ConfirmRecord;
            this.ViewRecord = (bool)menu.FullPermission ? true : (bool)menu.ViewRecord;
            this.PrintRecord = (bool)menu.FullPermission ? true : (bool)menu.PrintRecord;
            this.SelectRecord = false;
            this.ViewRecordOwner = (bool)menu.FullPermission ? true : (bool)menu.ViewRecordOwner;
            this.EditRecordOwner = (bool)menu.FullPermission ? true : (bool)menu.EditRecordOwner;
            this.DisposeRecordOwner = (bool)menu.FullPermission ? true : (bool)menu.DisposeRecordOwner;
            this.ConfirmRecordOwner = (bool)menu.FullPermission ? true : (bool)menu.ConfirmRecordOwner;
            this.PrintRecordOwner = (bool)menu.FullPermission ? true : (bool)menu.PrintRecordOwner;
            this.ExtraParam = menu.ExtraParam;
        }

        public bool EditRecord { get; set; }

        public bool EditRecordOwner { get; set; }

        public bool ViewRecord { get; set; }

        public bool ViewRecordOwner { get; set; }

        public bool AddRecord { get; set; }

        public bool DisposeRecord { get; set; }

        public bool DisposeRecordOwner { get; set; }

        public bool ConfirmRecord { get; set; }

        public bool ConfirmRecordOwner { get; set; }

        public bool SelectRecord { get; set; }

        public bool PrintRecord { get; set; }

        public bool PrintRecordOwner { get; set; }

        public string ExtraParam { get; set; }
    }
}
